package com.macro.mall.config;

import com.macro.mall.util.Constants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 该类主要是在SpringBoot 启动后初始化一些基本类的信息
 *
 * @author by jicai on 2019/9/4.
 */
@Component
public class ApplicationStartSettingConfig {

    @Value("${spring.profiles.active}")
    private String active;

    @Value("${spring.application.name}")
    private String applicationName;

    @Value("${switch.sms}")
    private Boolean sms;

    @PostConstruct
    public void init() {
        Constants.PROFILE_ACTIVE = active;
        Constants.APPLICATION_NAME = applicationName;
        Constants.IS_PRO_PRE = "prod".equals(active);
        Constants.SWITCH_SMS = sms;
    }

}

